package com.film.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.film.domain.User;
import com.film.service.OrderService;
import com.film.service.impl.OrderServiceImpl;

/*6.13 14.54*/
@WebServlet("/removeOrder.do")
public class RemoveOrderController extends HttpServlet{
	
	private OrderService orderService = new OrderServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String orderNum = request.getParameter("orderNum");
		String  flag = request.getParameter("flag");
		int result = orderService.removeOrder(orderNum);
		if(flag.equals("1")) {
			//从支付页面过来的，支付超时了，回到首页
//			response.sendRedirect("index");
		}else if(flag.equals("2")){
			//在我的订单中直接删除的订单，回到我的订单  
			HttpSession session = request.getSession();
			User user = (User)session.getAttribute("userLogin");
			response.sendRedirect("order.do?uid="+user.getuId());
		}
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doGet(req, resp);
	}
}
